﻿#region DaContract
/*----------------------------------------------------------------
// 文件名：DaContract.cs
// 功能描述：表dbo.Contract的数据访问层
//
// 
// 创建时间：2009-11-20 DtataAccess template . Ver 5.0.20090413
//
// 修改标识： 
// 修改描述： 
//----------------------------------------------------------------*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data;
using System.Globalization;
using System.Text;
using System.Data.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;

using EQT.Model;


namespace EQT.Dal
{
    ///可以继承更上层接口,IContract ,数据访问层基类DaBase，
    ///DaBase中包含了DbException异常处理静态方法
    public partial class DaContract : DaBase<MoContract>
    {
        #region SQL const
        internal const string TABLE_COLUMNS = " REPORT_ID ,UID ,CLIENT_ID ,CORP_NAME ,CONSIGNER ,LINKMAN ,TEL ,PHONE ,FAX ,ADDR ,POSTCODE ,EMAIL ,CHARGE ,REPORT_STATUS ,REPORT_URL ,TOTAL_PRICE ,CREATE_TIME ,UPDATE_TIME   ";

        internal const string SQL_INSERT = "INSERT INTO CONTRACT (" + TABLE_COLUMNS + ") VALUES (@ReportId,@Uid,@ClientId,@CorpName,@Consigner,@Linkman,@Tel,@Phone,@Fax,@Addr,@Postcode,@Email,@Charge,@ReportStatus,@ReportUrl,@TotalPrice,@CreateTime,@UpdateTime)";
        internal const string SQL_SELECT = "SELECT " + TABLE_COLUMNS + " FROM CONTRACT  ";
        internal const string SQL_SELECT_ONE = SQL_SELECT + " WHERE REPORT_ID=@ReportId";

        internal const string SQL_EXIST = "SELECT COUNT(*) FROM CONTRACT  WHERE REPORT_ID=@ReportId  ";
        internal const string SQL_UPDATE = "UPDATE CONTRACT SET UID=@Uid, CLIENT_ID=@ClientId, CORP_NAME=@CorpName, CONSIGNER=@Consigner, LINKMAN=@Linkman, TEL=@Tel, PHONE=@Phone, FAX=@Fax, ADDR=@Addr, POSTCODE=@Postcode, EMAIL=@Email, CHARGE=@Charge, REPORT_STATUS=@ReportStatus, REPORT_URL=@ReportUrl, TOTAL_PRICE=@TotalPrice, CREATE_TIME=@CreateTime, UPDATE_TIME=@UpdateTime WHERE REPORT_ID=@ReportId";

        internal const string SQL_DELETE_DEFAULT = "DELETE FROM CONTRACT ";
        internal const string SQL_DELETE = "DELETE FROM CONTRACT WHERE REPORT_ID=@ReportId";

        internal const string SQL_COUNT = "SELECT COUNT(*) FROM Contract ";
        #endregion

        #region Constructor

        /// <summary>
        /// 默认构造函数，使用配置文件中默认的数据库配置。
        /// </summary>
        public DaContract()
        {
            this.db = DatabaseFactory.CreateDatabase();
        }
        /// <summary>
        /// 使用指定的databaseName数据库配置。
        /// </summary>
        /// <param name="databaseName">配置文件中数据库的配置名称。</param>
        public DaContract(string databaseName)
        {
            this.db = DatabaseFactory.CreateDatabase(databaseName);
        }

        public DaContract(Database db)
        {
            this.db = db;
        }

        #endregion

        //以下是CRUD方法，每个方法都有引入外部事务的版本

        #region 构造器模块

        internal override MoContract ConstructT()
        {
            return new MoContract();
        }
        #endregion



        #region Add模块 Helper

        ///build the command object.It never throw exception.
        internal override DbCommand ConstructAddCommand(Database db)
        {
            DbCommand dbCommand = db.GetSqlStringCommand(SQL_INSERT);

            db.AddInParameter(dbCommand, "ReportId", DbType.AnsiString);
            db.AddInParameter(dbCommand, "Uid", DbType.AnsiString);
            db.AddInParameter(dbCommand, "ClientId", DbType.AnsiString);
            db.AddInParameter(dbCommand, "CorpName", DbType.String);
            db.AddInParameter(dbCommand, "Consigner", DbType.String);
            db.AddInParameter(dbCommand, "Linkman", DbType.String);
            db.AddInParameter(dbCommand, "Tel", DbType.AnsiString);
            db.AddInParameter(dbCommand, "Phone", DbType.AnsiString);
            db.AddInParameter(dbCommand, "Fax", DbType.AnsiString);
            db.AddInParameter(dbCommand, "Addr", DbType.String);
            db.AddInParameter(dbCommand, "Postcode", DbType.AnsiString);
            db.AddInParameter(dbCommand, "Email", DbType.AnsiString);
            db.AddInParameter(dbCommand, "Charge", DbType.Decimal);
            db.AddInParameter(dbCommand, "ReportStatus", DbType.Int32);
            db.AddInParameter(dbCommand, "ReportUrl", DbType.String);
            db.AddInParameter(dbCommand, "TotalPrice", DbType.Decimal);
            db.AddInParameter(dbCommand, "CreateTime", DbType.DateTime);
            db.AddInParameter(dbCommand, "UpdateTime", DbType.DateTime);
            return dbCommand;
        }
        internal override DbCommand ConstructAddCommand(Database db, MoContract entity)
        {
            DbCommand dbCommand = db.GetSqlStringCommand(SQL_INSERT);
            db.AddInParameter(dbCommand, "ReportId", DbType.AnsiString, entity.ReportId);
            db.AddInParameter(dbCommand, "Uid", DbType.AnsiString, entity.Uid);
            db.AddInParameter(dbCommand, "ClientId", DbType.AnsiString, entity.ClientId);
            db.AddInParameter(dbCommand, "CorpName", DbType.String, entity.CorpName);
            db.AddInParameter(dbCommand, "Consigner", DbType.String, entity.Consigner);
            db.AddInParameter(dbCommand, "Linkman", DbType.String, entity.Linkman);
            db.AddInParameter(dbCommand, "Tel", DbType.AnsiString, entity.Tel);
            db.AddInParameter(dbCommand, "Phone", DbType.AnsiString, entity.Phone);
            db.AddInParameter(dbCommand, "Fax", DbType.AnsiString, entity.Fax);
            db.AddInParameter(dbCommand, "Addr", DbType.String, entity.Addr);
            db.AddInParameter(dbCommand, "Postcode", DbType.AnsiString, entity.Postcode);
            db.AddInParameter(dbCommand, "Email", DbType.AnsiString, entity.Email);
            db.AddInParameter(dbCommand, "Charge", DbType.Decimal, entity.Charge);
            db.AddInParameter(dbCommand, "ReportStatus", DbType.Int32, entity.ReportStatus);
            db.AddInParameter(dbCommand, "ReportUrl", DbType.String, entity.ReportUrl);
            db.AddInParameter(dbCommand, "TotalPrice", DbType.Decimal, entity.TotalPrice);
            db.AddInParameter(dbCommand, "CreateTime", DbType.DateTime, entity.CreateTime);
            db.AddInParameter(dbCommand, "UpdateTime", DbType.DateTime, entity.UpdateTime);
            return dbCommand;
        }

        internal override DbCommand PopulateAddCommandParameters(Database db, DbCommand addCmd, MoContract entity)
        {
            db.SetParameterValue(addCmd, "ReportId", entity.ReportId);
            db.SetParameterValue(addCmd, "Uid", entity.Uid);
            db.SetParameterValue(addCmd, "ClientId", entity.ClientId);
            db.SetParameterValue(addCmd, "CorpName", entity.CorpName);
            db.SetParameterValue(addCmd, "Consigner", entity.Consigner);
            db.SetParameterValue(addCmd, "Linkman", entity.Linkman);
            db.SetParameterValue(addCmd, "Tel", entity.Tel);
            db.SetParameterValue(addCmd, "Phone", entity.Phone);
            db.SetParameterValue(addCmd, "Fax", entity.Fax);
            db.SetParameterValue(addCmd, "Addr", entity.Addr);
            db.SetParameterValue(addCmd, "Postcode", entity.Postcode);
            db.SetParameterValue(addCmd, "Email", entity.Email);
            db.SetParameterValue(addCmd, "Charge", entity.Charge);
            db.SetParameterValue(addCmd, "ReportStatus", entity.ReportStatus);
            db.SetParameterValue(addCmd, "ReportUrl", entity.ReportUrl);
            db.SetParameterValue(addCmd, "TotalPrice", entity.TotalPrice);
            db.SetParameterValue(addCmd, "CreateTime", entity.CreateTime);
            db.SetParameterValue(addCmd, "UpdateTime", entity.UpdateTime);
            return addCmd;
        }

        internal override DbCommand PopulateAddCommandParameters(Database db, DbCommand addCmd, DataRow row)
        {
            db.SetParameterValue(addCmd, "ReportId", row["ReportId"]);
            db.SetParameterValue(addCmd, "Uid", row["Uid"]);
            db.SetParameterValue(addCmd, "ClientId", row["ClientId"]);
            db.SetParameterValue(addCmd, "CorpName", row["CorpName"]);
            db.SetParameterValue(addCmd, "Consigner", row["Consigner"]);
            db.SetParameterValue(addCmd, "Linkman", row["Linkman"]);
            db.SetParameterValue(addCmd, "Tel", row["Tel"]);
            db.SetParameterValue(addCmd, "Phone", row["Phone"]);
            db.SetParameterValue(addCmd, "Fax", row["Fax"]);
            db.SetParameterValue(addCmd, "Addr", row["Addr"]);
            db.SetParameterValue(addCmd, "Postcode", row["Postcode"]);
            db.SetParameterValue(addCmd, "Email", row["Email"]);
            db.SetParameterValue(addCmd, "Charge", row["Charge"]);
            db.SetParameterValue(addCmd, "ReportStatus", row["ReportStatus"]);
            db.SetParameterValue(addCmd, "ReportUrl", row["ReportUrl"]);
            db.SetParameterValue(addCmd, "TotalPrice", row["TotalPrice"]);
            db.SetParameterValue(addCmd, "CreateTime", row["CreateTime"]);
            db.SetParameterValue(addCmd, "UpdateTime", row["UpdateTime"]);
            return addCmd;
        }

        #endregion

        #region Update模块 Helper

        internal override DbCommand ConstructUpdateCommand(Database db)
        {
            DbCommand dbCommand = db.GetSqlStringCommand(SQL_UPDATE);
            db.AddInParameter(dbCommand, "Uid", DbType.AnsiString);
            db.AddInParameter(dbCommand, "ClientId", DbType.AnsiString);
            db.AddInParameter(dbCommand, "CorpName", DbType.String);
            db.AddInParameter(dbCommand, "Consigner", DbType.String);
            db.AddInParameter(dbCommand, "Linkman", DbType.String);
            db.AddInParameter(dbCommand, "Tel", DbType.AnsiString);
            db.AddInParameter(dbCommand, "Phone", DbType.AnsiString);
            db.AddInParameter(dbCommand, "Fax", DbType.AnsiString);
            db.AddInParameter(dbCommand, "Addr", DbType.String);
            db.AddInParameter(dbCommand, "Postcode", DbType.AnsiString);
            db.AddInParameter(dbCommand, "Email", DbType.AnsiString);
            db.AddInParameter(dbCommand, "Charge", DbType.Decimal);
            db.AddInParameter(dbCommand, "ReportStatus", DbType.Int32);
            db.AddInParameter(dbCommand, "ReportUrl", DbType.String);
            db.AddInParameter(dbCommand, "TotalPrice", DbType.Decimal);
            db.AddInParameter(dbCommand, "CreateTime", DbType.DateTime);
            db.AddInParameter(dbCommand, "UpdateTime", DbType.DateTime);
            db.AddInParameter(dbCommand, "ReportId", DbType.AnsiString);

            return dbCommand;
        }
        internal override DbCommand ConstructUpdateCommand(Database db, MoContract entity)
        {
            DbCommand dbCommand = db.GetSqlStringCommand(SQL_UPDATE);
            db.AddInParameter(dbCommand, "Uid", DbType.AnsiString, entity.Uid);
            db.AddInParameter(dbCommand, "ClientId", DbType.AnsiString, entity.ClientId);
            db.AddInParameter(dbCommand, "CorpName", DbType.String, entity.CorpName);
            db.AddInParameter(dbCommand, "Consigner", DbType.String, entity.Consigner);
            db.AddInParameter(dbCommand, "Linkman", DbType.String, entity.Linkman);
            db.AddInParameter(dbCommand, "Tel", DbType.AnsiString, entity.Tel);
            db.AddInParameter(dbCommand, "Phone", DbType.AnsiString, entity.Phone);
            db.AddInParameter(dbCommand, "Fax", DbType.AnsiString, entity.Fax);
            db.AddInParameter(dbCommand, "Addr", DbType.String, entity.Addr);
            db.AddInParameter(dbCommand, "Postcode", DbType.AnsiString, entity.Postcode);
            db.AddInParameter(dbCommand, "Email", DbType.AnsiString, entity.Email);
            db.AddInParameter(dbCommand, "Charge", DbType.Decimal, entity.Charge);
            db.AddInParameter(dbCommand, "ReportStatus", DbType.Int32, entity.ReportStatus);
            db.AddInParameter(dbCommand, "ReportUrl", DbType.String, entity.ReportUrl);
            db.AddInParameter(dbCommand, "TotalPrice", DbType.Decimal, entity.TotalPrice);
            db.AddInParameter(dbCommand, "CreateTime", DbType.DateTime, entity.CreateTime);
            db.AddInParameter(dbCommand, "UpdateTime", DbType.DateTime, entity.UpdateTime);
            db.AddInParameter(dbCommand, "ReportId", DbType.AnsiString, entity.ReportId);

            return dbCommand;
        }

        internal override DbCommand PopulateUpdateCommandParameters(Database db, DbCommand updateCmd, MoContract entity)
        {
            db.SetParameterValue(updateCmd, "Uid", entity.Uid);
            db.SetParameterValue(updateCmd, "ClientId", entity.ClientId);
            db.SetParameterValue(updateCmd, "CorpName", entity.CorpName);
            db.SetParameterValue(updateCmd, "Consigner", entity.Consigner);
            db.SetParameterValue(updateCmd, "Linkman", entity.Linkman);
            db.SetParameterValue(updateCmd, "Tel", entity.Tel);
            db.SetParameterValue(updateCmd, "Phone", entity.Phone);
            db.SetParameterValue(updateCmd, "Fax", entity.Fax);
            db.SetParameterValue(updateCmd, "Addr", entity.Addr);
            db.SetParameterValue(updateCmd, "Postcode", entity.Postcode);
            db.SetParameterValue(updateCmd, "Email", entity.Email);
            db.SetParameterValue(updateCmd, "Charge", entity.Charge);
            db.SetParameterValue(updateCmd, "ReportStatus", entity.ReportStatus);
            db.SetParameterValue(updateCmd, "ReportUrl", entity.ReportUrl);
            db.SetParameterValue(updateCmd, "TotalPrice", entity.TotalPrice);
            db.SetParameterValue(updateCmd, "CreateTime", entity.CreateTime);
            db.SetParameterValue(updateCmd, "UpdateTime", entity.UpdateTime);
            db.SetParameterValue(updateCmd, "ReportId", entity.ReportId);
            return updateCmd;
        }
        internal override DbCommand PopulateUpdateCommandParameters(Database db, DbCommand updateCmd, DataRow row)
        {
            db.SetParameterValue(updateCmd, "Uid", row["Uid"]);
            db.SetParameterValue(updateCmd, "ClientId", row["ClientId"]);
            db.SetParameterValue(updateCmd, "CorpName", row["CorpName"]);
            db.SetParameterValue(updateCmd, "Consigner", row["Consigner"]);
            db.SetParameterValue(updateCmd, "Linkman", row["Linkman"]);
            db.SetParameterValue(updateCmd, "Tel", row["Tel"]);
            db.SetParameterValue(updateCmd, "Phone", row["Phone"]);
            db.SetParameterValue(updateCmd, "Fax", row["Fax"]);
            db.SetParameterValue(updateCmd, "Addr", row["Addr"]);
            db.SetParameterValue(updateCmd, "Postcode", row["Postcode"]);
            db.SetParameterValue(updateCmd, "Email", row["Email"]);
            db.SetParameterValue(updateCmd, "Charge", row["Charge"]);
            db.SetParameterValue(updateCmd, "ReportStatus", row["ReportStatus"]);
            db.SetParameterValue(updateCmd, "ReportUrl", row["ReportUrl"]);
            db.SetParameterValue(updateCmd, "TotalPrice", row["TotalPrice"]);
            db.SetParameterValue(updateCmd, "CreateTime", row["CreateTime"]);
            db.SetParameterValue(updateCmd, "UpdateTime", row["UpdateTime"]);
            db.SetParameterValue(updateCmd, "ReportId", row["ReportId"]);
            return updateCmd;
        }

        internal override void PrepareDataAdapterCommand(Database db, out DbCommand dbInsertCommand,
                             out DbCommand dbUpdateCommand, out DbCommand dbDeleteCommand)
        {
            dbInsertCommand = db.GetSqlStringCommand(SQL_INSERT);
            #region set insert cmd parameters
            db.AddInParameter(dbInsertCommand, "ReportId", DbType.AnsiString, "REPORT_ID", DataRowVersion.Current);
            db.AddInParameter(dbInsertCommand, "Uid", DbType.AnsiString, "UID", DataRowVersion.Current);
            db.AddInParameter(dbInsertCommand, "ClientId", DbType.AnsiString, "CLIENT_ID", DataRowVersion.Current);
            db.AddInParameter(dbInsertCommand, "CorpName", DbType.String, "CORP_NAME", DataRowVersion.Current);
            db.AddInParameter(dbInsertCommand, "Consigner", DbType.String, "CONSIGNER", DataRowVersion.Current);
            db.AddInParameter(dbInsertCommand, "Linkman", DbType.String, "LINKMAN", DataRowVersion.Current);
            db.AddInParameter(dbInsertCommand, "Tel", DbType.AnsiString, "TEL", DataRowVersion.Current);
            db.AddInParameter(dbInsertCommand, "Phone", DbType.AnsiString, "PHONE", DataRowVersion.Current);
            db.AddInParameter(dbInsertCommand, "Fax", DbType.AnsiString, "FAX", DataRowVersion.Current);
            db.AddInParameter(dbInsertCommand, "Addr", DbType.String, "ADDR", DataRowVersion.Current);
            db.AddInParameter(dbInsertCommand, "Postcode", DbType.AnsiString, "POSTCODE", DataRowVersion.Current);
            db.AddInParameter(dbInsertCommand, "Email", DbType.AnsiString, "EMAIL", DataRowVersion.Current);
            db.AddInParameter(dbInsertCommand, "Charge", DbType.Decimal, "CHARGE", DataRowVersion.Current);
            db.AddInParameter(dbInsertCommand, "ReportStatus", DbType.Int32, "REPORT_STATUS", DataRowVersion.Current);
            db.AddInParameter(dbInsertCommand, "ReportUrl", DbType.String, "REPORT_URL", DataRowVersion.Current);
            db.AddInParameter(dbInsertCommand, "TotalPrice", DbType.Decimal, "TOTAL_PRICE", DataRowVersion.Current);
            db.AddInParameter(dbInsertCommand, "CreateTime", DbType.DateTime, "CREATE_TIME", DataRowVersion.Current);
            db.AddInParameter(dbInsertCommand, "UpdateTime", DbType.DateTime, "UPDATE_TIME", DataRowVersion.Current);
            #endregion
            dbUpdateCommand = db.GetSqlStringCommand(SQL_UPDATE);
            #region Set update cmd value parameters
            db.AddInParameter(dbUpdateCommand, "Uid", DbType.AnsiString, "UID", DataRowVersion.Current);
            db.AddInParameter(dbUpdateCommand, "ClientId", DbType.AnsiString, "CLIENT_ID", DataRowVersion.Current);
            db.AddInParameter(dbUpdateCommand, "CorpName", DbType.String, "CORP_NAME", DataRowVersion.Current);
            db.AddInParameter(dbUpdateCommand, "Consigner", DbType.String, "CONSIGNER", DataRowVersion.Current);
            db.AddInParameter(dbUpdateCommand, "Linkman", DbType.String, "LINKMAN", DataRowVersion.Current);
            db.AddInParameter(dbUpdateCommand, "Tel", DbType.AnsiString, "TEL", DataRowVersion.Current);
            db.AddInParameter(dbUpdateCommand, "Phone", DbType.AnsiString, "PHONE", DataRowVersion.Current);
            db.AddInParameter(dbUpdateCommand, "Fax", DbType.AnsiString, "FAX", DataRowVersion.Current);
            db.AddInParameter(dbUpdateCommand, "Addr", DbType.String, "ADDR", DataRowVersion.Current);
            db.AddInParameter(dbUpdateCommand, "Postcode", DbType.AnsiString, "POSTCODE", DataRowVersion.Current);
            db.AddInParameter(dbUpdateCommand, "Email", DbType.AnsiString, "EMAIL", DataRowVersion.Current);
            db.AddInParameter(dbUpdateCommand, "Charge", DbType.Decimal, "CHARGE", DataRowVersion.Current);
            db.AddInParameter(dbUpdateCommand, "ReportStatus", DbType.Int32, "REPORT_STATUS", DataRowVersion.Current);
            db.AddInParameter(dbUpdateCommand, "ReportUrl", DbType.String, "REPORT_URL", DataRowVersion.Current);
            db.AddInParameter(dbUpdateCommand, "TotalPrice", DbType.Decimal, "TOTAL_PRICE", DataRowVersion.Current);
            db.AddInParameter(dbUpdateCommand, "CreateTime", DbType.DateTime, "CREATE_TIME", DataRowVersion.Current);
            db.AddInParameter(dbUpdateCommand, "UpdateTime", DbType.DateTime, "UPDATE_TIME", DataRowVersion.Current);
            #endregion
            #region set update cmd pk where parameters
            db.AddInParameter(dbUpdateCommand, "ReportId", DbType.AnsiString, "REPORT_ID", DataRowVersion.Current);
            #endregion
            dbDeleteCommand = db.GetSqlStringCommand(SQL_DELETE);
            #region set delete cmd pk where parameters
            db.AddInParameter(dbDeleteCommand, "ReportId", DbType.AnsiString, "REPORT_ID", DataRowVersion.Current);
            #endregion
        }
        #endregion

        #region Delete模块 Helper

        internal override DbCommand ConstructDeleteCommand(Database db)
        {
            DbCommand dbCommand = db.GetSqlStringCommand(SQL_DELETE);

            db.AddInParameter(dbCommand, "ReportId", DbType.AnsiString);

            return dbCommand;
        }
        internal override DbCommand ConstructDeleteCommand(Database db, MoContract entity)
        {
            DbCommand dbCommand = db.GetSqlStringCommand(SQL_DELETE);

            db.AddInParameter(dbCommand, "ReportId", DbType.AnsiString, entity.ReportId);

            return dbCommand;
        }

        internal override DbCommand ConstructDeleteCommandForWhere(Database db, string where)
        {
            return db.GetSqlStringCommand(SQL_DELETE_DEFAULT + where);
        }

        internal override DbCommand PopulateDeleteCommandParameters(Database db, DbCommand deleteCmd, MoContract entity)
        {
            db.SetParameterValue(deleteCmd, "ReportId", entity.ReportId);
            return deleteCmd;
        }

        internal override DbCommand PopulateDeleteCommandParameters(Database db, DbCommand deleteCmd, DataRow row)
        {
            db.SetParameterValue(deleteCmd, "ReportId", row["ReportId"]);
            return deleteCmd;
        }

        #endregion helper

        #region Query模块 Helper

        internal override DbCommand ConstructQueryCommand(string condition)
        {
            return db.GetSqlStringCommand(SQL_SELECT + condition);
        }

        #endregion

        #region GetEntity(s)模块 Helper

        internal override DbCommand ConstructSelectOneCommand(Database db, MoContract entity)
        {
            DbCommand dbCommand = db.GetSqlStringCommand(SQL_SELECT_ONE);

            db.AddInParameter(dbCommand, "ReportId", DbType.AnsiString, entity.ReportId);
            return dbCommand;
        }

        internal override void PopulateEntityByDataReader(IDataReader reader, ref MoContract entity)
        {
            if (!reader.IsDBNull(0)) entity.ReportId = reader.GetString(0);
            if (!reader.IsDBNull(1)) entity.Uid = reader.GetString(1);
            if (!reader.IsDBNull(2)) entity.ClientId = reader.GetString(2);
            if (!reader.IsDBNull(3)) entity.CorpName = reader.GetString(3);
            if (!reader.IsDBNull(4)) entity.Consigner = reader.GetString(4);
            if (!reader.IsDBNull(5)) entity.Linkman = reader.GetString(5);
            if (!reader.IsDBNull(6)) entity.Tel = reader.GetString(6);
            if (!reader.IsDBNull(7)) entity.Phone = reader.GetString(7);
            if (!reader.IsDBNull(8)) entity.Fax = reader.GetString(8);
            if (!reader.IsDBNull(9)) entity.Addr = reader.GetString(9);
            if (!reader.IsDBNull(10)) entity.Postcode = reader.GetString(10);
            if (!reader.IsDBNull(11)) entity.Email = reader.GetString(11);
            if (!reader.IsDBNull(12)) entity.Charge = reader.GetDecimal(12);
            if (!reader.IsDBNull(13)) entity.ReportStatus = reader.GetInt32(13);
            if (!reader.IsDBNull(14)) entity.ReportUrl = reader.GetString(14);
            if (!reader.IsDBNull(15)) entity.TotalPrice = reader.GetDecimal(15);
            if (!reader.IsDBNull(16)) entity.CreateTime = reader.GetDateTime(16);
            if (!reader.IsDBNull(17)) entity.UpdateTime = reader.GetDateTime(17);
        }



        internal override DbCommand ConstructSelectConditionCommand(Database db, string condition)
        {
            return db.GetSqlStringCommand(SQL_SELECT + condition);
        }

        #endregion

        #region Count模块 Helper

        internal override DbCommand ConstructCountCommand(Database db)
        {
            return db.GetSqlStringCommand(SQL_COUNT);
        }

        internal override DbCommand ConstructCountConditionCommand(Database db, string condition)
        {
            return db.GetSqlStringCommand(SQL_COUNT + condition);
        }

        #endregion

        #region IsExist模块 Helper

        internal override DbCommand ConstructIsExistCommand(Database db, MoContract entity)
        {
            DbCommand dbCommand = db.GetSqlStringCommand(SQL_EXIST);
            db.AddInParameter(dbCommand, "ReportId", DbType.AnsiString, entity.ReportId);
            return dbCommand;
        }

        #endregion



    }
}
#endregion

